

const EventEmitterUtils = (function(){
     var unique;

     function ConstructFun(){

         this.events = {}

         this.on=(eventName, fn)=>{
             let fnList = this.events[eventName] || [];
             fnList.push(fn)
             if (eventName) {
                 this.events[eventName] = fnList;
             }
         }

         this.emit=(eventName, ...agr)=> {
             let funcs = this.events[eventName];
             if (funcs && funcs.length) {
                 for (let j = 0; j < funcs.length; j++) {
                     funcs[j](...agr);
                 }
             }
         }

         this.off=(eventName, fn)=>{
             let funcs = this.events[eventName];
             if (fn) {
                 this.events[eventName].splice(fn, 1);
             } else {
                 delete this.events[eventName]
             }
         }

     }

     unique = new ConstructFun()
     return unique
 })()


 export default EventEmitterUtils

